package com.css.zfzx.sjcj.modules.drill.controller;

import com.css.bpm.platform.base.response.RestResponse;
import com.css.zfzx.sjcj.modules.drill.service.MutipleSheetExcelPoiService;
import com.css.zfzx.sjcj.modules.drill.viewobjects.QhY02QueryParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Description
 * @Author zyc
 * @Date 2021/1/15 17:12
 * @Version V1.0
 */
@RestController
@RequestMapping("/qh/drill")

public class MutipleSheetPoiController {
    @Autowired
    MutipleSheetExcelPoiService mutipleSheetExcelPoiService;

    /**
     * 导入多sheet Excel文件
     */
    @PostMapping("/importMultiSheet")
    public RestResponse importMultiSheetExcel(@RequestParam("file") MultipartFile excelFile) {
        return mutipleSheetExcelPoiService.importMultiSheetExcel(excelFile);
    }


    /**
     * 导出多sheet Excel文件
     */
    @GetMapping("/exportMultiSheet/{ids}")
    public RestResponse exportMultiSheetExcel(HttpServletResponse response, @PathVariable List<String> ids) {
        return mutipleSheetExcelPoiService.multipleSheetZipExports(response, ids);
    }
    @GetMapping("/exportMultiSheets")
    public void exportMultiSheetsExcel(@RequestParam String province, @RequestParam String city, @RequestParam String area,
                                       @RequestParam String village, @RequestParam String drillSynthesizeCode,
                                       @RequestParam String dataSourceType, @RequestParam String dataState,
                                       HttpServletResponse response) {
        QhY02QueryParams queryParams=new QhY02QueryParams();
        queryParams.setProvince(province);
        queryParams.setCity(city);
        queryParams.setArea(area);
        queryParams.setVillage(village);
        queryParams.setDrillSynthesizeCode(drillSynthesizeCode);
        queryParams.setDataSourceType(dataSourceType);
        queryParams.setDataState(dataState);
        mutipleSheetExcelPoiService.multipleSheetsZipExports(response, queryParams);
    }
}
